import { createRouter, createWebHistory } from 'vue-router'
import Login from '@/views/Login/index.vue'
import SalesLayout from '@/views/Sales/Layout/index.vue'
import Home from '@/views/Sales/Home/index.vue'
import Category from '@/views/Sales/Category/index.vue'
import SubCategory from '@/views/Sales/SubCategory/index.vue'
import Detail from '@/views/Sales/Detail/index.vue'
// import CartList from '@/views/Sales/CartList/index.vue'
// import Checkout from '@/views/Sales/Checkout/index.vue'
// import Pay from '@/views/Sales/Pay/index.vue'
// import PayBack from '@/views/Sales/Pay/PayBack.vue'
import Member from '@/views/Sales/Member/index.vue'
import UserInfo from '@/views/Sales/Member/components/UserInfo.vue'
import UserOrder from '@/views/Sales/Member/components/UserOrder.vue'

import AdminLayout from '@/views/Admin/Layout/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: SalesLayout,
      children: [
        {
          path: '',
          component: Home
        },
        {
          path: 'category/:id',
          component: Category
        },
        {
          path: 'category/sub/:id',
          component: SubCategory
        },
        {
          path: 'detail/:id',
          component: Detail
        },
        // {
        //   path: 'cartlist',
        //   component: CartList
        // },
        // {
        //   path: 'checkout',
        //   component: Checkout
        // },
        // {
        //   path: 'pay',
        //   component: Pay
        // },
        // {
        //   path: 'paycallback', // 注意路径，必须是paycallback
        //   component: PayBack
        // },
        {
          path: 'member',
          component: Member,
          children: [
            {
              path: '',
              component: UserInfo
            },
            {
              path: 'order',
              component: UserOrder
            }
          ]
        }
      ]
    },
    {
      path: '/login',
      component: Login
    },
    {
      path: '/admin',
      component: AdminLayout
    }
  ],
  // 路由切换时，页面回到顶部
  scrollBehavior() {
    return {
      top: 0
    }
  }
})

export default router
